/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package simplepushserver;

import java.io.Serializable;
import java.text.SimpleDateFormat;
import java.util.Calendar;

/**
 *
 * @author Filip
 */
public class LogEntry implements Serializable{
    private static final SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    private String time;
    private String source;
    private String action;
    private String content;

    public LogEntry() {}
    private static final long serialVersionUID = 1337;

    public LogEntry(String source, String action, String content) {
        this.time = sdf.format(Calendar.getInstance().getTime());
        this.source = source;
        this.action = action;
        this.content = content;
    }

    public LogEntry(String time, String source, String action, String content) {
        this.time = time;
        this.source = source;
        this.action = action;
        this.content = content;
    }
    
    
    @Override
    public String toString() {
        return getTime()+" - "+getSource()+" - "+getAction()+" - "+getContent();
    }

    @Override
    public boolean equals(Object obj) {
        if(obj!=null && obj.getClass()==this.getClass()){
            LogEntry l = (LogEntry) obj;
            if(getTime().equals(l.getTime()) && 
                    getSource().equals(l.getSource()) &&
                    getAction().equals(l.getAction()) &&
                    getContent().equals(l.getContent())){
                return true;
            }
        }
        return false;
    }

    @Override
    public int hashCode() {
        int hash = 7;
        hash = 59 * hash + (this.getTime() != null ? this.getTime().hashCode() : 0);
        hash = 59 * hash + (this.getSource() != null ? this.getSource().hashCode() : 0);
        hash = 59 * hash + (this.getAction() != null ? this.getAction().hashCode() : 0);
        hash = 59 * hash + (this.getContent() != null ? this.getContent().hashCode() : 0);
        return hash;
    }

    /**
     * @return the time
     */
    public String getTime() {
        return time;
    }

    /**
     * @return the source
     */
    public String getSource() {
        return source;
    }

    /**
     * @return the action
     */
    public String getAction() {
        return action;
    }

    /**
     * @return the content
     */
    public String getContent() {
        return content;
    }
    
}
